package com.bothin.experiment4.handler;

import com.bothin.experiment4.exception.SellException;
import org.springframework.security.access.AccessDeniedException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;


/**
 * Created by bothin
 * At 2019/12/22 9:35
 * Description:
 */
@ControllerAdvice
public class HandlerControllerException {

    @ExceptionHandler(RuntimeException.class)
    public String handleException(RuntimeException e){
        if (e instanceof AccessDeniedException){
            return "redirect:/error/notice/403";
        }else if (e instanceof SellException){
            return "redirect:/error/notice/500";
        }
        return "redirect:/error/notice/500";
    }
}
